package com.kfm.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 所有 File 文件相关的请求都由这个 Servlet 处理
 *
 * 请求  /file
 * 调用 service(ServletRequest, ServletResponse)  HttpServlet
 * 调用 service(HttpServletRequest, HttpServletResponse) HttpServlet
 * 根据请求的 method 去调用 doGet/doPost 等等  BaseServlet
 * 调用 doService  FileServlet
 */
//@WebServlet("/file")
public class FileServlet extends BaseServlet {


    @Override
    public void doService(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String type = req.getParameter("type");

        switch (type) {
            case "upload":
                upload(req, resp);
                break;
            case "download":
                download(req, resp);
                break;
            default:
                break;
        }
    }

    private void download(HttpServletRequest req, HttpServletResponse resp) {
    }

    private void upload(HttpServletRequest req, HttpServletResponse resp) {
    }
}
